# def bin_search(items, key):
#     begin, end = 0, len(items) - 1
#     while begin <= end:
#         mid = (begin + end) // 2
#         if key < items[mid]:
#             end = mid - 1
#         elif key > items[mid]:
#             begin = mid + 1
#         else:
#             return mid
#     return -1
#
#
# my_list = [35, 47, 58, 66, 72, 95, 98]
# print(bin_search(my_list, 35))
# print(bin_search(my_list, 98))
# print(bin_search(my_list, 66))
# print(bin_search(my_list, 55))


def find_max(items):
    begin, end = 0, len(items) - 1
    while begin < end - 1:
        mid = (begin + end) // 2
        rmid = (mid + end) // 2
        if items[mid] > items[rmid]:
            end = rmid
        else:
            begin = mid
    return items[begin]


thy_list = [35, 47, 58, 66, 72, 95, 98, 88, 77, 65, 32, 19]
print(find_max(thy_list))
